<?php
/**
 * Descript:
 * User: blue
 * Date: 2018/8/916:08
 */

namespace app\api\model;


use app\lib\exception\TokenException;
use think\Model;

class CmsUser extends Model
{
    protected $table="third_user";

    /**
     * @param $uname
     * @param $pwd
     */
    public static function userValid($name,$pwd){
        $user=self::where('app_id',$name)->findOrFail()->visible(['id','app_id','scope']);
        if(!password_verify($pwd,$user['app_secret'])){throw new TokenException(['message'=>'密码不正确']);}
        return $user;
    }
}